//
//  TouristsDetailsViewController.m
//  EMMApp
//
//  Created by Mac on 16/5/18.
//  Copyright © 2016年 YiXun. All rights reserved.
//

#import "TouristsDetailsViewController.h"
#import "NewCustomersCell.h"
#import "TouristsDetailsOneCell.h"
#import "ToutistsHomeViewCell.h"
#import "TourKHXXCell.h"

#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>

#import "KnowViewController.h"
#import "SubscriptionViewController.h"
#import "SignViewController.h"
#import "NewFromViewController.h"
#import <MessageUI/MessageUI.h>
#import "FollowUpViewController.h"
#import "AddCustomersViewController.h"

#import <AVFoundation/AVFoundation.h>
#import <AddressBookUI/AddressBookUI.h>
#import <AddressBook/AddressBook.h>

#import "QueryProjectQuestionnaireListApi.h"        //自定义问卷Api
#import "GetTagListApi.h"                           //获取标签分类

#import "EMMBaseWebViewController.h"

#import "GetCustomerDetailApi.h"
#import "GetConsultantListApi.h"
#import "DistributionConsultantApi.h"
#import "GetFollowListApi.h"
#import "FollowOneCell.h"
#import "FollowTwoCell.h"
#import "EMMTouristsCell.h"

#import "FollowThreeCell.h"
#import "EMMImageView.h"
#import "GetDictionaryListApi.h"
#import "MHPhotoBrowserController.h"

#import "NewCustDetailsCell.h"
#import "YCXMenu.h"

@interface TouristsDetailsViewController ()<UITableViewDataSource,UITableViewDelegate,UITextFieldDelegate,MFMessageComposeViewControllerDelegate,AVAudioPlayerDelegate,ABPeoplePickerNavigationControllerDelegate>
{
    UITableView *_tableView;
    NSMutableDictionary *dic;//存对应的数据
    NSMutableArray *selectedArr;//二级列表是否展开状态
    NSArray *dataArray;//数据源，显示每个cell的数据
    NSMutableDictionary *stateDic;//三级列表是否展开状态
    NSMutableArray *grouparr0;
    NSMutableArray *grouparr1;
    NSMutableArray *grouparr2;
    NSInteger heightCell;
    NSInteger number;
    
    ABAddressBookRef addBook;
    BOOL _isBoy;
    NSString *boy;
    

    
}

//详情模块
@property (nonatomic, strong) NSMutableArray *titleDataArray;

@property (nonatomic, assign) NSInteger moreCellHight;

@property (nonatomic, strong) NSArray *menuItems;
@property (nonatomic, strong) NSArray *memImageViewArr;
@property (nonatomic, strong) GetCustomerDetail *getCustomerDetail;

@property (nonatomic, strong) NSMutableArray *zyData;
@property (nonatomic, strong) NSMutableArray *zyDataArr;
@property (nonatomic, strong) NSMutableArray *zyDataArrId;
@property (nonatomic, strong) GetConsultantList *getConsultantList;
@property (nonatomic, strong) NSMutableArray *gjDataArr;
@property (nonatomic, strong) AVAudioPlayer *player;


@property (nonatomic,strong) PlayAnimationView *playView;

@property (nonatomic, assign) BOOL iszkFlas;

/**
 右按钮弹出框数组
 */
@property (nonatomic, strong) NSMutableArray *itmesNewArr;

@property (nonatomic, assign) int subCellHightRow1;//关注重点
@property (nonatomic, strong) NSMutableArray *gzzdArr;    //关注重点
@property (nonatomic, strong) UITableView *subCellIndeRow1TableView;

//意向房源
@property (nonatomic, assign) int subCellHightRow4;
@property (nonatomic, strong) NSMutableArray *zongRoomList; //意向房源
@property (nonatomic, strong) UITableView *subCellIndeRow4TableView;
@property (nonatomic, strong) NSMutableArray *roomList; //意向房源

//生活服务
@property (nonatomic, assign) int subCellHightRow5;
@property (nonatomic, strong) UITableView *subCellIndeRow5TableView;
@property (nonatomic, strong) NSMutableArray *customeServicesArr;

//首次沟通
@property (nonatomic, strong) NSMutableArray *grouparr3;

//客户信息
@property (nonatomic, strong) NSMutableArray *grouparr4;

//自定义问卷列表
@property (nonatomic, strong) NSMutableArray *questionnaireListDataArr;
@property (nonatomic, strong) NSMutableArray *grouparr5;//自定义问卷

//获取标签分类列表
@property (nonatomic, strong) NSMutableArray *getTagListDataArray;
@property (nonatomic, strong) NSMutableArray *grouparr6;//获取标签分类

@end

@implementation TouristsDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self postGetConsultantListApi];
    [self creatNavigationController];
    dic = [[NSMutableDictionary alloc] init];
    selectedArr = [[NSMutableArray alloc] init];
    dataArray = [[NSArray alloc] init];
    _gzzdArr = [[NSMutableArray alloc] init];
    _roomList = [[NSMutableArray alloc] init];
    _zongRoomList = [[NSMutableArray alloc] init];
    _customeServicesArr = [[NSMutableArray alloc] init];
    _questionnaireListDataArr = [[NSMutableArray alloc] init];
    _getTagListDataArray = [[NSMutableArray alloc] init];
    
    _subCellHightRow1 = 50;
    _subCellHightRow4 = 50;
    _subCellHightRow5 = 50;
    _grouparr5 = [[NSMutableArray alloc] init];
    _grouparr6 = [[NSMutableArray alloc] init];
    _zyData = [[NSMutableArray alloc] init];
    _zyDataArr = [[NSMutableArray alloc] init];
    
    [self postGetCustomerDetailApi];
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH,EMM_HEIGHT-49-SafeAreaTopHeight) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.showsVerticalScrollIndicator = NO;
    //不要分割线
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    [self initDataSource];
    [self creat];

    [self getPromiseFor_isDistributionCustomer_isAddPaydeposit];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(backPushNotification:) name:@"isBackPushNotification" object:nil];
}



-(void )getPromiseFor_isDistributionCustomer_isAddPaydeposit{
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *isDistributionCustomer = [userdf objectForKey:@"isDistributionCustomer"];
    NSString *isAddPaydeposit = [userdf objectForKey:@"isAddPaydeposit"];
    _itmesNewArr = [@[
                      [YCXMenuItem menuItem:@"添加到通讯录"
                                      image:[UIImage imageNamed:@"more_message"]
                                        tag:100
                                   userInfo:nil],
                      ] mutableCopy];
    if ([isAddPaydeposit isEqualToString:@"1"]) {//新增认筹-0、未开通；1、已开通
        [_itmesNewArr addObject:[YCXMenuItem menuItem:@"新增认筹"
                                                image:[UIImage imageNamed:@"more_form"]
                                                  tag:100
                                             userInfo:nil]];
    }
    if ([isDistributionCustomer isEqualToString:@"1"]) {//客户分配-0、未开通；1、已开通
        [_itmesNewArr addObject: [YCXMenuItem menuItem:@"分配"
                                                 image:[UIImage imageNamed:@"more_allot"]
                                                   tag:100
                                              userInfo:nil]];
    }
}



- (void)backPushNotification:(NSNotification *)notification {
    [self dismissViewControllerAnimated:NO completion:^{
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    _gjDataArr = [[NSMutableArray alloc] init];
    [self postGetFollowListApi];
}

#pragma  mark - post请求跟进列表数据
- (void)postGetFollowListApi{
    [_gjDataArr removeAllObjects];
   
    GetFollowListApi *api = [[GetFollowListApi alloc] initWithCustomerId:self.customerId];
    
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetFollowListApi *result = (GetFollowListApi *)request;
        if (result.isSuccess) {
            GetFollowList *get = result.resultData;
            for (FollowList *list in get.followList) {
                [_gjDataArr addObject:list];
            }
        
        } else {
            [self showToast:result.resultData.errorMsg];
            
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
       
        [_tableView reloadData];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
       
    }];
}

#pragma  mark - 经纪人
- (void)postGetConsultantListApi {
    [_zyDataArr removeAllObjects];
    [_zyData removeAllObjects];
    GetConsultantListApi *api = [[GetConsultantListApi alloc] initWithResourcesCode:nil searchType:nil];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetConsultantListApi *result = (GetConsultantListApi *)request;
        if (result.isSuccess) {
            GetConsultantList *get = result.resultData;
            _getConsultantList = get;
            for (ConsultantList *list in get.consultantList) {
                [_zyDataArr addObject:list.consultantUserName];
                [_zyData addObject:list];
                
            }
        } else {
//            [self showToast:result.resultData.errorMsg];
            
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
    }];
}

#pragma mark - api查看客户详情
- (void)postGetCustomerDetailApi {
    [_roomList removeAllObjects];
    [_zongRoomList removeAllObjects];
    [_gzzdArr removeAllObjects];
    [_customeServicesArr removeAllObjects];
    
    [self showHud:@"正在加载请稍等..."];
    GetCustomerDetailApi *api = [[GetCustomerDetailApi alloc] initWithCustomerId:self.customerId];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetCustomerDetailApi *result = (GetCustomerDetailApi *)request;
        if (result.isSuccess) {
           GetCustomerDetail *get = result.resultData;
            _getCustomerDetail = get;
         
            for (CustomerFocusList *list in get.customerFocusList) {
                [_gzzdArr addObject:list];
            }
            _subCellHightRow1 = (int)_gzzdArr.count * 50 + 50;
            for (RoomList *list in get.roomList) {
                [_zongRoomList addObject:list];
            }
            if (_zongRoomList.count > 3) {
                RoomList *list = [_zongRoomList objectAtIndex:0];
                [_roomList addObject:list];
                RoomList *list1 = [_zongRoomList objectAtIndex:1];
                [_roomList addObject:list1];
                RoomList *list2 = [_zongRoomList objectAtIndex:2];
                [_roomList addObject:list2];
                _subCellHightRow4 = (int)_roomList.count * 50 + 100;
                _iszkFlas = YES;
            }else {
                if (_zongRoomList.count > 0 ) {
                    if (_zongRoomList.count == 1) {
                        RoomList *list = [_zongRoomList objectAtIndex:0];
                        [_roomList addObject:list];
                    }else if (_zongRoomList.count == 2) {
                        RoomList *list = [_zongRoomList objectAtIndex:0];
                        [_roomList addObject:list];
                        RoomList *list1 = [_zongRoomList objectAtIndex:1];
                        [_roomList addObject:list1];
                    }else if (_zongRoomList.count == 3) {
                        RoomList *list = [_zongRoomList objectAtIndex:0];
                        [_roomList addObject:list];
                        RoomList *list1 = [_zongRoomList objectAtIndex:1];
                        [_roomList addObject:list1];
                        RoomList *list2 = [_zongRoomList objectAtIndex:2];
                        [_roomList addObject:list2];
                    }
                }
                _subCellHightRow4 = (int)_roomList.count * 50 + 50;
            }

            for (CustomeServicesList *list in get.customeServicesList) {
                [_customeServicesArr addObject:list];
            }
            _subCellHightRow5 = (int)_customeServicesArr.count * 50 + 50;
            
            [self postQueryProjectQuestionnaireListApi];
            [self GetTagListApi];
            [self initDataSource];
        } else {
            //[self showToast:result.resultData.errorMsg];
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            NSString *projectCode = [userdf objectForKey:@"projectCode"];
            if ([NSString isStringEmpty2:projectCode] == NO) {
                [self showToast:result.resultData.errorMsg];
            }
            
            /*
             提示语：账号权限发生变动，请重新登录
             code随机18位唯一码：108E65843mYuwqb01X
             //YUplf0wyU5vPVssLSG 对应的异地登录退出登录
             */
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];

        [_subCellIndeRow1TableView reloadData];
        [_subCellIndeRow4TableView reloadData];
        [_subCellIndeRow5TableView reloadData];
        [_tableView reloadData];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}


#pragma mark - 导航

- (void)creatNavigationController {
    [self updateNavBar];
    self.navigationItem.title = @"客户详情";
//    [self configLeftBtn];
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"ioc_3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(rightClick:)];
    [self.navigationItem setRightBarButtonItem:rightItme];
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setFrame:CGRectMake(0, 0, 54 ,44)];
    [backBtn addTarget:self
                action:@selector(backToPreviousPage:)
      forControlEvents:UIControlEventTouchUpInside];
    [backBtn setBackgroundColor:[UIColor clearColor]];
    [backBtn setImage:[UIImage imageNamed:@"ico_back"] forState:UIControlStateNormal];
    backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    if (EMM_WIDTH <= 320) {
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }else if (EMM_WIDTH > 375){
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -10, 0, 0);
    }else{
        backBtn.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
    }
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backBtn];
}

#pragma mark - 导航左按钮响应事件 -----

- (void)backToPreviousPage:(UIButton *)btn {
    if (_isNot == YES) {
        [self dismissViewControllerAnimated:YES completion:^{
            
        }];
    }else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)rightClick:(UIButton *)btn {
    [YCXMenu setTintColor:[UIColor colorFromHexCode:@"#FB5B3B"]];
    [YCXMenu setSelectedColor:[UIColor colorFromHexCode:@"#FB5B3B"]];
    [YCXMenu setSeparatorColor:[UIColor colorFromHexCode:@"#CCCCCC"]];
    [YCXMenu setTitleFont:[UIFont systemFontOfSize:15]];
    if ([YCXMenu isShow]){
        [YCXMenu dismissMenu];
    } else {
        [YCXMenu showMenuInView:self.view fromRect:CGRectMake(self.view.frame.size.width - 55, 0, 50, 0) menuItems:_itmesNewArr selected:^(NSInteger index, YCXMenuItem *item) {
            [self creatYCXMenuShowUI:index];
        }];
    }
}

#pragma mark - 右按钮弹出框
- (void)creatYCXMenuShowUI:(NSInteger)index {
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *isDistributionCustomer = [userdf objectForKey:@"isDistributionCustomer"];
    //客户菜单权限下按钮权限：客户分配
    
    //是否已开通认筹功能：0、未开通；1、已开通
    NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
    
    if ([isDistributionCustomer isEqualToString:@"1"]) {
        if ([isPaydeposit isEqualToString:@"0"]) {
            if (index == 0) {
                [self creatPhoneAdd];
            }else if (index == 1) {
                ShowMenuView *menuView = [[ShowMenuView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) title:@"选项" titleNmae:@"经纪人" numLits:nil items:_zyDataArr];
                menuView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                [[UIApplication sharedApplication].keyWindow addSubview:menuView];
                __weak ShowMenuView *weakMenuView = menuView;
                [menuView setTouchBlock:^(NSString *indet,NSString *numStrring) {
                    NSLog(@"%@",indet);
                    if ([NSString isStringEmpty2:indet] == NO) {
                        ConsultantList *consList = [_zyData objectAtIndex:[numStrring intValue]-1];
                        NSString *consultantId = consList.consultantUserId;
                        NSArray *arr = @[@{@"customerId":_customerId}];
                        [self postDistributionConsultantApiConsultantUserId:consultantId customerList:arr];
                    }
                    [weakMenuView removeFromSuperview];
                   
                }];
            }
        }else if ([isPaydeposit isEqualToString:@"1"]) {
            if (index == 0) {
                [self creatPhoneAdd];
            }else if (index == 1) {
                ShowMenuView *menuView = [[ShowMenuView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) title:@"选项" titleNmae:@"经纪人" numLits:nil items:_zyDataArr];
                menuView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                [[UIApplication sharedApplication].keyWindow addSubview:menuView];
                __weak ShowMenuView *weakMenuView = menuView;
                [menuView setTouchBlock:^(NSString *indet,NSString *numStrring) {
                    NSLog(@"%@",indet);
                    if ([NSString isStringEmpty2:indet] == NO) {
                        ConsultantList *consList = [_zyData objectAtIndex:[numStrring intValue]-1];
                        NSString *consultantId = consList.consultantUserId;
                        NSArray *arr = @[@{@"customerId":_customerId}];
                        [self postDistributionConsultantApiConsultantUserId:consultantId customerList:arr];
                    }
                    [weakMenuView removeFromSuperview];
                    
                }];
            }else if (index == 2) {
                NewFromViewController *nvc = [[NewFromViewController alloc] init];
                nvc.isFrom = @"0";
                nvc.customerId = self.customerId;
                [self.navigationController pushViewController:nvc animated:YES];
            }
        }else {
            if (index == 0) {
                [self creatPhoneAdd];
            }else if (index == 1) {
                ShowMenuView *menuView = [[ShowMenuView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) title:@"选项" titleNmae:@"经纪人" numLits:nil items:_zyDataArr];
                menuView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                [[UIApplication sharedApplication].keyWindow addSubview:menuView];
                __weak ShowMenuView *weakMenuView = menuView;
                [menuView setTouchBlock:^(NSString *indet,NSString *numStrring) {
                    NSLog(@"%@",indet);
                    if ([NSString isStringEmpty2:indet] == YES) {
                        ConsultantList *consList = [_zyData objectAtIndex:[numStrring intValue]-1];
                        NSString *consultantId = consList.consultantUserId;
                        NSArray *arr = @[@{@"customerId":_customerId}];
                        [self postDistributionConsultantApiConsultantUserId:consultantId customerList:arr];
                    }
                    [weakMenuView removeFromSuperview];
                    
                }];
            }else if (index == 2) {
                NewFromViewController *nvc = [[NewFromViewController alloc] init];
                nvc.isFrom = @"0";
                nvc.customerId = self.customerId;
                [self.navigationController pushViewController:nvc animated:YES];
            }
        }
    }else {
        if ([isPaydeposit isEqualToString:@"0"]) {
            if (index == 0) {
                [self creatPhoneAdd];
            }
        }else if ([isPaydeposit isEqualToString:@"1"]) {
            if (index == 0) {
                [self creatPhoneAdd];
            }else if (index == 1) {
                NewFromViewController *nvc = [[NewFromViewController alloc] init];
                nvc.isFrom = @"0";
                nvc.customerId = self.customerId;
                [self.navigationController pushViewController:nvc animated:YES];
            }
        }else {
            if (index == 0) {
                [self creatPhoneAdd];
            }else if (index == 1) {
                NewFromViewController *nvc = [[NewFromViewController alloc] init];
                nvc.isFrom = @"0";
                nvc.customerId = self.customerId;
                [self.navigationController pushViewController:nvc animated:YES];
            }
        }
    }
}



#pragma mark - 增加用户信息到手机通讯录
- (void)creatPhoneAdd {
    [self getAddressBook];
    [self AddPeopleWithFirstName:_getCustomerDetail.customerName WithLastName:nil  withPhoneNum:_getCustomerDetail.customerPhone ];
}
-(void)AddPeopleWithFirstName:(NSString *)firstName WithLastName:(NSString *)lastName withPhoneNum:(NSString *)phoneNum {
    ABRecordRef person = ABPersonCreate();
    //        NSString *firstName = @"粉丝";
    //        NSString *lastName = @"001";
    // 电话号码数组
    //NSArray *phones = [NSArray arrayWithObjects:@"1234",@"456",nil];
    NSArray *phones = [NSArray arrayWithObjects:phoneNum,nil];
    
    // 电话号码对应的名称
    //    NSArray *labels = [NSArray arrayWithObjects:@"iphone",@"home",nil];
    NSArray *labels = [NSArray arrayWithObjects:@"iphone",nil];
    
    //这里的字段和上面的字段完全相同
    // 设置名字属性
    ABRecordSetValue(person, kABPersonFirstNameProperty,(__bridge CFStringRef)firstName, NULL);
    // 设置姓氏属性
    ABRecordSetValue(person, kABPersonLastNameProperty, (__bridge CFStringRef)lastName, NULL);
    // 设置生日属性
    // ABRecordSetValue(person, kABPersonBirthdayProperty,(__bridge CFDateRef)birthday, NULL);
    // 字典引用
    ABMultiValueRef dic =ABMultiValueCreateMutable(kABMultiStringPropertyType);
    // 添加电话号码与其对应的名称内容
    for (int i = 0; i < [phones count]; i ++) {
        ABMultiValueIdentifier obj = ABMultiValueAddValueAndLabel(dic,(__bridge CFStringRef)[phones objectAtIndex:i], (__bridge CFStringRef)[labels objectAtIndex:i], &obj);
    }
    // 设置phone属性
    ABRecordSetValue(person, kABPersonPhoneProperty, dic, NULL);
    
    //为联系人添加头像
    UIImage *image =  [UIImage imageNamed:@"img07"];
    ABPersonSetImageData (person,(__bridge CFDataRef)UIImagePNGRepresentation(image),nil);
    
    // 将新建的联系人添加到通讯录中
    ABAddressBookAddRecord(addBook, person, NULL);
    // 保存通讯录数据
    ABAddressBookSave(addBook, NULL);
}

-(void)getAddressBook{
    int __block tip=0;
    //声明一个通讯簿的引用
    addBook =nil;
    //因为在IOS6.0之后和之前的权限申请方式有所差别，这里做个判断
    if ([[UIDevice currentDevice].systemVersion floatValue]>=6.0) {
        //创建通讯簿的引用
        addBook=ABAddressBookCreateWithOptions(NULL, NULL);
        //创建一个出事信号量为0的信号
        dispatch_semaphore_t sema=dispatch_semaphore_create(0);
        //申请访问权限
        ABAddressBookRequestAccessWithCompletion(addBook, ^(bool greanted, CFErrorRef error)        {
            //greanted为YES是表示用户允许，否则为不允许
            if (!greanted) {
                tip=1;
            }
            //发送一次信号
            dispatch_semaphore_signal(sema);
        });
        //等待信号触发
        dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
    }else{
        //IOS6之前
        addBook =ABAddressBookCreate();
    }
    if (tip) {
        //做一个友好的提示
        [self showToast:@"添加失败"];
        return;
    }else {
        [self showToast:@"添加成功"];
    }
    
}

- (void)creat {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, EMM_HEIGHT-SafeAreaBottomHeight-SafeAreaTopHeight, EMM_WIDTH, SafeAreaBottomHeight)];
    view.backgroundColor = [UIColor colorFromHexCode:@"ff7200"];
    [self.view addSubview:view];
    UIImageView *image1 = [[UIImageView alloc] initWithFrame:CGRectMake((EMM_WIDTH/4-35)/2, 0, 35, 35)];
    image1.image = [UIImage imageNamed:@"xq_icon_tel"];
    [view addSubview:image1];
    UILabel *l1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 29, EMM_WIDTH/4, 20)];
    l1.text = @"打电话";
    l1.font = [UIFont systemFontOfSize:12];
    l1.textColor = [UIColor whiteColor];
    l1.textAlignment = NSTextAlignmentCenter;
    [view addSubview:l1];
    UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeSystem];
    btn1.frame = CGRectMake(0, 0, EMM_WIDTH/4, view.frame.size.height);
    [btn1 addTarget:self action:@selector(btn1Click:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn1];
    
    UIImageView *image2 = [[UIImageView alloc] initWithFrame:CGRectMake((EMM_WIDTH/4-35)/2+EMM_WIDTH/4, 0, 35, 35)];
    image2.image = [UIImage imageNamed:@"xq_icon_email"];
    [view addSubview:image2];
    UILabel *l2 = [[UILabel alloc] initWithFrame:CGRectMake(EMM_WIDTH/4, 29, EMM_WIDTH/4, 20)];
    l2.text = @"发短信";
    l2.font = [UIFont systemFontOfSize:12];
    l2.textColor = [UIColor whiteColor];
    l2.textAlignment = NSTextAlignmentCenter;
    [view addSubview:l2];
    UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeSystem];
    btn2.frame = CGRectMake(EMM_WIDTH/4, 0, EMM_WIDTH/4, view.frame.size.height);
    [btn2 addTarget:self action:@selector(btn2Click:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn2];
    
    UIImageView *image3 = [[UIImageView alloc] initWithFrame:CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4+(EMM_WIDTH/4-35)/2, 0, 35, 35)];
    image3.image = [UIImage imageNamed:@"xq_icon_edit"];
    [view addSubview:image3];
    UILabel *l3 = [[UILabel alloc] initWithFrame:CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4, 29, EMM_WIDTH/4, 20)];
    l3.text = @"写跟进";
    l3.font = [UIFont systemFontOfSize:12];
    l3.textColor = [UIColor whiteColor];
    l3.textAlignment = NSTextAlignmentCenter;
    [view addSubview:l3];
    UIButton *btn3 = [UIButton buttonWithType:UIButtonTypeSystem];
    btn3.frame = CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4 , 0, EMM_WIDTH/4, view.frame.size.height);
    [btn3 addTarget:self action:@selector(btn3Click:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn3];
    
    UIImageView *image4 = [[UIImageView alloc] initWithFrame:CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4+EMM_WIDTH/4+(EMM_WIDTH/4-35)/2, 0, 35, 35)];
    image4.image = [UIImage imageNamed:@"xq_icon_follow"];
    [view addSubview:image4];
    UILabel *l4 = [[UILabel alloc] initWithFrame:CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4+EMM_WIDTH/4, 29, EMM_WIDTH/4, 20)];
    l4.text = @"编辑";
    l4.font = [UIFont systemFontOfSize:12];
    l4.textColor = [UIColor whiteColor];
    l4.textAlignment = NSTextAlignmentCenter;
    [view addSubview:l4];
    UIButton *btn4 = [UIButton buttonWithType:UIButtonTypeSystem];
    btn4.frame = CGRectMake(EMM_WIDTH/4+EMM_WIDTH/4+EMM_WIDTH/4, 0, EMM_WIDTH/4, view.frame.size.height);
    [btn4 addTarget:self action:@selector(btn4Click:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn4];
}

- (void)btn1Click:(UIButton *)btn {
//
//    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
//    
//    NSString *isPhoneInformation = [userdf objectForKey:@"isPhoneInformation"];
//    if ([NSString isStringEmpty2:isPhoneInformation] == NO) {
//        if ([isPhoneInformation isEqualToString:@"0"]) {
//            [self creatinitWithGetPhone:_getCustomerDetail.customerPhone];
//
//        }else if ([isPhoneInformation isEqualToString:@"1"]) {
//            [self postGetUserCallListApiFlog:@"1"];
//        }
//    }else {
//        [self creatinitWithGetPhone:_getCustomerDetail.customerPhone];
//
//    }
        [self postGetUserCallListApi];
    


 
    
}

- (void)btn2Click:(UIButton *)btn {
    NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:_getCustomerDetail.customerPhone, nil];
    [self creatinitWithGetNoteArr:arr];
}

- (void)btn3Click:(UIButton *)btn {
    FollowUpViewController *fvc = [[FollowUpViewController alloc] init];
    fvc.customerId = _customerId;
    [self.navigationController pushViewController:fvc animated:YES];
    [fvc setFollowUpViewBlock:^{

    }];
}

- (void)btn4Click:(UIButton *)btn {
    AddCustomersViewController *fvc = [[AddCustomersViewController alloc] init];
    fvc.isflg = YES;
    fvc.getCustomerDetail = _getCustomerDetail;
    fvc.customerId = self.customerId;
    [self.navigationController pushViewController:fvc animated:YES];
    [fvc setNewCustomersBlock:^{
        [self postGetCustomerDetailApi];
    }];
}

#pragma mark - 本地打电话
- (void)creatinitWithGetPhone:(NSString *)phonString {
    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phonString];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];
//    NSLog(@"1");
//    [self postGetUserCallListApi];
}

#pragma mark - 发短信
- (void)creatinitWithGetNoteArr:(NSMutableArray *)dxArr {
    
    if( [MFMessageComposeViewController canSendText] ){
        MFMessageComposeViewController * controller = [[MFMessageComposeViewController alloc]init];
        controller.recipients = dxArr;
//        controller.body = @"测试发短信";
        controller.messageComposeDelegate = self;
        [self presentViewController:controller animated:YES completion:^{
            
        }];
        [[[[controller viewControllers] lastObject] navigationItem] setTitle:nil];//修改短信界面标题
    }else{
        [self alertWithTitle:@"提示信息" msg:@"设备没有短信功能"];
    }
}

#pragma mark - MFMessageComposeViewControllerDelegate发短信协议代理方法调用
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    [controller dismissViewControllerAnimated:NO completion:^{
    }];
    switch ( result ) {
        case MessageComposeResultCancelled:
            [self alertWithTitle:@"提示信息" msg:@"发送取消"];
            break;
        case MessageComposeResultFailed:// send failed
            [self alertWithTitle:@"提示信息" msg:@"发送失败"];
            break;
        case MessageComposeResultSent:
            [self alertWithTitle:@"提示信息" msg:@"发送成功"];
            break;
        default:
            break;
    }
}


-(void)initDataSource {
    _titleDataArray = [[NSMutableArray alloc] initWithObjects:@"客户信息",@"跟进",@"需求信息",@"首次接触信息",@"客户个人信息",@"自定义问卷",@"客户标签", nil];
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *necessary = [userdf objectForKey:@"necessary"];
   
    if ([NSString isStringEmpty2:_getCustomerDetail.informedWay] == NO) {
        if ([ _getCustomerDetail.informedWay isEqualToString:@"外部推荐"]|| [_getCustomerDetail.informedWay isEqualToString:@"全员营销"]) {
            if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                 grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"获知途径",@"推荐人类别",@"推荐人姓名",@"推荐人手机号",@"推荐人单位",@"意向等级备注",@"", nil];
            }else {
                 grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"获知途径",@"推荐人类别",@"推荐人姓名",@"推荐人手机号",@"推荐人单位",@"", nil];
            }
        }else {
            if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"获知途径",@"意向等级备注",@"", nil];
            }else {
                grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"获知途径",@"", nil];
            }
        }
    }else {
        if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
            grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"意向等级备注",@"", nil];
        }else {
            grouparr0 = [[NSMutableArray alloc] initWithObjects:@"",@"", nil];
        }
    }
    
    grouparr1 = [[NSMutableArray alloc] initWithObjects:@"", nil];
    grouparr2 = [[NSMutableArray alloc]initWithObjects:@"置业动机",@"关注重点",@"需求面积",@"付款方式",@"生活服务",nil];

    
   
    _grouparr3 = [[NSMutableArray alloc] init];
    if (self.getCustomerDetail.ftContactTime && self.getCustomerDetail.ftContactWay) {
        [_grouparr3 addObject:@"首次接触方式"];
        [_grouparr3 addObject:@"首次接触时间"];
        [_grouparr3 addObject:@"沟通内容"];
    }
    if(self.getCustomerDetail.ftContactWay1 && self.getCustomerDetail.ftContactTime1) {
        [_grouparr3 addObject:@"首次接触方式"];
         [_grouparr3 addObject:@"首次接触时间"];
         [_grouparr3 addObject:@"沟通内容"];
    }
    
    _grouparr4 = [[NSMutableArray alloc] initWithObjects:@"居住区",@"工作区",@"从事行业",nil];
    
    [dic setValue:grouparr0 forKey:@"0"];
    [dic setValue:grouparr1 forKey:@"1"];
    [dic setValue:grouparr2 forKey:@"2"];
    [dic setValue:_grouparr3 forKey:@"3"];
    [dic setValue:_grouparr4 forKey:@"4"];

    selectedArr = [[NSMutableArray alloc] initWithObjects:@"0",@"1",@"2", nil];
    [_tableView reloadData];
}

#pragma mark----tableViewDelegate
//返回几个表头
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if (tableView == _subCellIndeRow1TableView) {//关注重点
        return 1;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return 1;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return 1;
    }
    return _titleDataArray.count;
}

//每一个表头下返回几行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if (tableView == _subCellIndeRow1TableView) {//关注重点
        return _gzzdArr.count;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return _roomList.count;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return _customeServicesArr.count;
    }
    NSString *string = [NSString stringWithFormat:@"%ld",section];
    if ([selectedArr containsObject:string]) {
        if ([string isEqualToString:@"1"]) {
            return _gjDataArr.count;
        }
        NSArray *array1 = dic[string];
        return array1.count;
    }
    return 0;
}

//设置表头的高度
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (tableView == _tableView) {
        if (section == 0) {
            return 80;
        }
    }else if (tableView == _subCellIndeRow1TableView) {//关注重点
        return 0.1f;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return 0.1f;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return 0.1f;
    }
    return 50;
}

//Section Footer的高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    if (tableView == _subCellIndeRow1TableView) {//关注重点
        return 0.2f;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return 0.2f;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return 0.2f;
    }
    return 5;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, 5)];
    view.backgroundColor = [UIColor clearColor];
    return view;
}

//设置view，将替代titleForHeaderInSection方法
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (tableView == _subCellIndeRow1TableView) {//关注重点
        return nil;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return nil;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return nil;
    }
    NSInteger gM1 = 0;
    if (section == 0) {
        gM1 = 80;
    }else {
        gM1 = 50;
    }
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, gM1)];
    UIView *viewOneSW = [[UIView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, 30)];
    viewOneSW.backgroundColor = [UIColor whiteColor];
    if (section == 0) {
        [view addSubview:viewOneSW];
    }
  
    int w = [_getCustomerDetail.integrity intValue];
    if (section == 0) {
        gM1 = gM1 + 30;
        UIView *scetion1 = [[UIView alloc] initWithFrame:CGRectMake(2, 2.5, EMM_WIDTH-4, 25)];
        scetion1.backgroundColor = [UIColor colorFromHexCode:@"#e1e4e9"];
        scetion1.layer.masksToBounds = YES;
        scetion1.layer.cornerRadius = 2;
        [view addSubview:scetion1];
        UILabel *wl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH*(w*0.01), 25)];
        wl.backgroundColor = [UIColor colorFromHexCode:@"#ff7200"];
        wl.layer.masksToBounds = YES;
        wl.layer.cornerRadius = 2;
        wl.textColor = [UIColor whiteColor];
        wl.font = [UIFont systemFontOfSize:12];
        wl.textAlignment = NSTextAlignmentRight;
        NSString *str = @"%";
        [scetion1 addSubview:wl];
        if (w > 20) {
          wl.text = [NSString stringWithFormat:@"完整度%d%@",w,str];
        }else{
            UILabel *wanzhengduLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 160, 25)];
            wanzhengduLabel.text = [NSString stringWithFormat:@"完整度%d%@",w,str];
            wanzhengduLabel.font = [UIFont systemFontOfSize:12];
            wanzhengduLabel.textColor = [UIColor whiteColor];
            [scetion1 addSubview:wanzhengduLabel];
        }
    }
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, (gM1-20)/2, tableView.frame.size.width-20, 20)];
    titleLabel.text = [_titleDataArray objectAtIndex:section];
    titleLabel.font = [UIFont systemFontOfSize:16];
    titleLabel.textColor = [UIColor colorFromHexCode:@"#1A1A1A"];
    [view addSubview:titleLabel];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, EMM_WIDTH, gM1);
    button.tag = 100+section;
    [button addTarget:self action:@selector(doButton:) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:button];
    UILabel *sLabel6 = [[UILabel alloc] initWithFrame:CGRectMake(0, (gM1-30)/2, 4, 30)];
    sLabel6.backgroundColor = [UIColor colorFromHexCode:@"#fca639"];
    [view addSubview:sLabel6];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(EMM_WIDTH-30, (gM1-20)/2, 20, 20)];
    UIImageView *upImageView = [[UIImageView alloc] initWithFrame:CGRectMake(EMM_WIDTH-30, (gM1-10)/2, 20, 10)];
    
    view.backgroundColor = [UIColor colorFromHexCode:@"#fff5e9"];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    [view addSubview:imageView];
    [view addSubview:upImageView];
    
    NSString *string = [NSString stringWithFormat:@"%ld",section];
    if ([selectedArr containsObject:string]) {
        upImageView.image = [UIImage imageNamed:@"sanjt_down"];
    }else {
        upImageView.image = [UIImage imageNamed:@"sanjt_up"];
    }
    
    return view;
}
//设置行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (tableView == _subCellIndeRow1TableView) {//关注重点
        return 50;
    }else if (tableView == _subCellIndeRow4TableView) {//意向房源
        return 50;
    }else if (tableView == _subCellIndeRow5TableView) {//生活服务
        return 50;
    }
    NSString *indexStr = [NSString stringWithFormat:@"%ld",indexPath.section];
    if ([indexStr isEqualToString:@"0"]) {
        if (indexPath.row == 0) {
            return 90;
        }else {
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            NSString *necessary = [userdf objectForKey:@"necessary"];
            if ([NSString isStringEmpty2:_getCustomerDetail.informedWay] == NO) {
                if ([_getCustomerDetail.informedWay isEqualToString:@"外部推荐"] || [_getCustomerDetail.informedWay isEqualToString:@"全员营销"]) {
                    if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                        if (indexPath.row == 7) {
                            return 55;
                        }else {
                            return 50;
                        }
                    }else {
                        if (indexPath.row == 6) {
                            return 55;
                        }else {
                            return 50;
                        }
                    }
                    
                }else {
                    if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                        if (indexPath.row == 3) {
                            return 55;
                        }else {
                            return 50;
                        }
                    }else {
                        if (indexPath.row == 2) {
                            return 55;
                        }else {
                            return 50;
                        }
                    }
                    
                }
            }else {
                if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                    if (indexPath.row == 2) {
                        return 55;
                    }else {
                        return 50;
                    }
                }else {
                    if (indexPath.row == 1) {
                        return 55;
                    }
                }
               
            }
        }
        return 0;
    }else if ([indexStr isEqualToString:@"1"]) {
        FollowList *list = [_gjDataArr objectAtIndex:indexPath.row];
        NSMutableArray *arr = [[NSMutableArray alloc] init];
        if (list.contentList.count > 0) {
            for (ContentList *cList in list.contentList) {
                [arr addObject:cList];
            }
        }
        
        if (!([list.followType isEqualToString:@"2"] || [list.followType isEqualToString:@"3"])) {
            ContentList *cList = arr[0];
            NSInteger cellH = 0;
            NSInteger h = [self textHeightFromTextString:cList.followContent width:[UIScreen mainScreen].bounds.size.width-115 fontSize:15]+30;
            if (h <= 70) {
                cellH = 70;
            }else {
                cellH = h;
            }
            
            return cellH;
            
        }

        return 70;
    }else if ([indexStr isEqualToString:@"2"]) {
        //需求
        if (indexPath.row == 1) {
            return _subCellHightRow1;
        }else if (indexPath.row == 4) {
            return _subCellHightRow5;
        }
        return 50;
    }else if ([indexStr isEqualToString:@"3"]) {
        if (indexPath.row == 2 ) {
            CGSize titleSize = [_getCustomerDetail.ftContactContent boundingRectWithSize:CGSizeMake(EMM_WIDTH - 107, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
            if (titleSize.height == 0) {
                return 50;
            }
            return titleSize.height + 33;
        }else if (indexPath.row == 5) {
            CGSize titleSize = [_getCustomerDetail.ftContactContent1 boundingRectWithSize:CGSizeMake(EMM_WIDTH - 107, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
            if (titleSize.height == 0) {
                return 50;
            }
            return titleSize.height + 33;
        }
        return 50;
    }
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (tableView == _subCellIndeRow1TableView) {
        static NSString *CellIdentifier = @"ToutistsHomeViewCellId";
        ToutistsHomeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"ToutistsHomeViewCell" owner:self options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        CustomerFocusList *list = [_gzzdArr objectAtIndex:indexPath.row];
        cell.touistsNameLabel.text = list.focusName;
        if (_gzzdArr.count == indexPath.row+1) {
            UIImageView *line1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 49.5, EMM_WIDTH-20, 0.5)];
            line1.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
            [cell addSubview:line1];
        }
        return cell;
    }else if (tableView == _subCellIndeRow4TableView) {
        static NSString *CellIdentifier = @"ToutistsHomeViewCellId";
        ToutistsHomeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"ToutistsHomeViewCell" owner:self options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        RoomList *list = [_roomList objectAtIndex:indexPath.row];
        NSString *strUrl = [list.roomName stringByReplacingOccurrencesOfString:@"-->" withString:@"-"];
        cell.touistsNameLabel.text = strUrl;
        if (_roomList.count == indexPath.row+1) {
            UIImageView *line1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 49.5, EMM_WIDTH-20, 0.5)];
            line1.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
            [cell addSubview:line1];
        }
        return cell;
    }else if (tableView == _subCellIndeRow5TableView) {
        static NSString *CellIdentifier = @"ToutistsHomeViewCellId";
        ToutistsHomeViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"ToutistsHomeViewCell" owner:self options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        CustomeServicesList *list = [_customeServicesArr objectAtIndex:indexPath.row];
        cell.touistsNameLabel.text = list.servicesName;
        if (_customeServicesArr.count == indexPath.row+1) {
            UIImageView *line1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 49.5, EMM_WIDTH-20, 0.5)];
            line1.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
            [cell addSubview:line1];
        }
        return cell;
    }
    NSString *indexStr = [NSString stringWithFormat:@"%ld",indexPath.section];
    NSLog(@"%@",indexStr);
    if ([indexStr isEqualToString:@"0"]) {
        static NSString *CellIdentifier = @"TouristsDetailsOneCell";
        TouristsDetailsOneCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil) {
            cell = [[[NSBundle mainBundle] loadNibNamed:@"TouristsDetailsOneCell" owner:self options:nil] lastObject];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.userNameLabel.text = _getCustomerDetail.customerName;
        NSDictionary *attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15],};
        CGSize textSize = [_getCustomerDetail.customerName boundingRectWithSize:cell.frame.size options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
        if (textSize.width > self.view.frame.size.width - 150) {
            cell.nameWidthConst.constant = self.view.frame.size.width - 150;
            cell.nameHeightConst.constant = 45;
        }else {
            cell.nameWidthConst.constant = textSize.width + 10;
            cell.nameHeightConst.constant = 25;
        }
        
        
        [cell.phoneSDetailsbtn addTarget:self action:@selector(btn1Click:) forControlEvents:UIControlEventTouchUpInside];
        if (indexPath.row == 0) {
            if ([_getCustomerDetail.customerStar isEqualToString:@"是"]) {
                cell.customerStar.hidden = NO;
                cell.sexLabel.layer.masksToBounds = YES;
                cell.sexLabel.layer.cornerRadius = 5;
                cell.sexLabel.backgroundColor = [UIColor colorFromHexCode:@"#f7653e"];
                cell.sexLabel.text = _getCustomerDetail.customerSex;
                cell.gradeLabel.layer.masksToBounds = YES;
                cell.gradeLabel.layer.cornerRadius = 5;
                cell.gradeLabel.text = _getCustomerDetail.intentionLevel;
                cell.gradeLabel.backgroundColor = [UIColor colorFromHexCode:@"#f82b49"];
                cell.duoIm.hidden= YES;/*产品需求隐藏 多套标签显示*/
//                if ([NSString isStringEmpty2:_getCustomerDetail.isMoreTrade] == NO) {
//                    if ([_getCustomerDetail.isMoreTrade isEqualToString:@"1"]) {
//                        cell.duoIm.hidden= NO;
//                    }else {
//                        cell.duoIm.hidden= YES;
//                    }
//                }else {
//                    cell.duoIm.hidden= YES;
//                }
                
            }else {
                cell.customerStar.hidden = YES;
                cell.sex1Label.layer.masksToBounds = YES;
                cell.sex1Label.layer.cornerRadius = 5;
                cell.sex1Label.backgroundColor = [UIColor colorFromHexCode:@"#f7653e"];
                cell.sex1Label.text = _getCustomerDetail.customerSex;
                cell.grade1Label.layer.masksToBounds = YES;
                cell.grade1Label.layer.cornerRadius = 5;
                cell.grade1Label.text = _getCustomerDetail.intentionLevel;
                cell.grade1Label.backgroundColor = [UIColor colorFromHexCode:@"#f82b49"];
                cell.duo1Im.hidden= YES;/*产品需求隐藏 多套标签显示*/
//                if ([NSString isStringEmpty2:_getCustomerDetail.isMoreTrade] == NO) {
//                    if ([_getCustomerDetail.isMoreTrade isEqualToString:@"1"]) {
//                        cell.duo1Im.hidden= NO;
//                    }else {
//                        cell.duo1Im.hidden= YES;
//                    }
//                }else {
//                    cell.duo1Im.hidden= YES;
//                }
            }
            cell.phoneLabel.text = _getCustomerDetail.customerPhone;
            cell.kfLabel.text = _getCustomerDetail.customerOrigin;
            cell.kfLabel.textColor = [UIColor colorFromHexCode:@"#ff7200"];
            cell.qyLabel.text = _getCustomerDetail.customerStatus;
            cell.qyLabel.textColor = [UIColor colorFromHexCode:@"#ff7200"];
            cell.tourview.backgroundColor = [UIColor colorFromHexCode:@"#fff5e9"];
            
        }else {
            static NSString *CellIdentifier = @"NewCustDetailsCell";
            NewCustDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[NSBundle mainBundle] loadNibNamed:@"NewCustDetailsCell" owner:self options:nil] lastObject];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
            cell.nameLbael.font = [UIFont systemFontOfSize:15];
            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
            NSString *necessary = [userdf objectForKey:@"necessary"];
            
            if ([NSString isStringEmpty2:_getCustomerDetail.informedWay] == NO) {
                if ([_getCustomerDetail.informedWay isEqualToString:@"外部推荐"] || [_getCustomerDetail.informedWay isEqualToString:@"全员营销"]) {
                    cell.customLabel.hidden = NO;
                    UIImageView *lineIma1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 49.5, EMM_WIDTH-20, 0.5)];
                    lineIma1.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
                    if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                        if (indexPath.row != 6) {
                            [cell addSubview:lineIma1];
                        }
                        if (indexPath.row == 1) {
                            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 0.5)];
                            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
                            [cell addSubview:lineImage];
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.informedWay;
                        }else if (indexPath.row == 2) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedCategory;
                            
                        }else if (indexPath.row == 3) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedName;
                            
                        }else if (indexPath.row == 4) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedMobile;
                            
                        }else if (indexPath.row == 5) {
                            cell.customLabel.text = _getCustomerDetail.recommendedUnit;
                            
                        }else if (indexPath.row == 6) {
                            cell.customLabel.text = _getCustomerDetail.intentionLevelRemark;
                        }else if (indexPath.row == 7) {
                            cell.customLabel.hidden = YES;
                            cell.nameLbael.hidden = YES;
                            cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                            b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                            NSString *rcString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                            }else {
                                rcString = [NSString stringWithFormat:@"认筹 | "];
                                
                            }
                            [b1 setTitle:rcString forState:UIControlStateNormal];
                            [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b1.layer.masksToBounds = YES;
                            b1.layer.cornerRadius = 5;
                            [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b1];
                            
                            UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                            NSString *rgString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                            }else {
                                rgString = [NSString stringWithFormat:@"认购 | "];
                            }
                            [b2 setTitle:rgString forState:UIControlStateNormal];
                            [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b2.layer.masksToBounds = YES;
                            b2.layer.cornerRadius = 5;
                            [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b2];
                            
                            UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                            NSString *qyString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                            }else {
                                qyString = [NSString stringWithFormat:@"签约 | "];
                            }
                            
                            [b3 setTitle:qyString forState:UIControlStateNormal];
                            [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b3.layer.masksToBounds = YES;
                            b3.layer.cornerRadius = 5;
                            [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b3];
                            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                            //是否已开通认筹功能：0、未开通；1、已开通
                            NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                            if ([isPaydeposit isEqualToString:@"0"]) {
                                b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }else {
                                [cell addSubview:b1];
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }
                        }
                    }else {
                        if (indexPath.row != 6) {
                            [cell addSubview:lineIma1];
                        }
                        if (indexPath.row == 1) {
                            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 0.5)];
                            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
                            [cell addSubview:lineImage];
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.informedWay;
                        }else if (indexPath.row == 2) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedCategory;
                            
                        }else if (indexPath.row == 3) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedName;
                            
                        }else if (indexPath.row == 4) {
                            [cell addSubview:lineIma1];
                            cell.customLabel.text = _getCustomerDetail.recommendedMobile;
                            
                        }else if (indexPath.row == 5) {
                            cell.customLabel.text = _getCustomerDetail.recommendedUnit;
                            
                        }else if (indexPath.row == 6) {
                            cell.customLabel.hidden = YES;
                            cell.nameLbael.hidden = YES;
                            cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                            b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                            NSString *rcString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                            }else {
                                rcString = [NSString stringWithFormat:@"认筹 | "];
                                
                            }
                            [b1 setTitle:rcString forState:UIControlStateNormal];
                            [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b1.layer.masksToBounds = YES;
                            b1.layer.cornerRadius = 5;
                            [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b1];
                            
                            UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                            NSString *rgString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                            }else {
                                rgString = [NSString stringWithFormat:@"认购 | "];
                            }
                            [b2 setTitle:rgString forState:UIControlStateNormal];
                            [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b2.layer.masksToBounds = YES;
                            b2.layer.cornerRadius = 5;
                            [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b2];
                            
                            UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                            NSString *qyString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                            }else {
                                qyString = [NSString stringWithFormat:@"签约 | "];
                            }
                            
                            [b3 setTitle:qyString forState:UIControlStateNormal];
                            [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b3.layer.masksToBounds = YES;
                            b3.layer.cornerRadius = 5;
                            [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b3];
                            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                            //是否已开通认筹功能：0、未开通；1、已开通
                            NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                            if ([isPaydeposit isEqualToString:@"0"]) {
                                b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }else {
                                [cell addSubview:b1];
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }
                        }
                    }
                    
                }else {
                    if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                        if (indexPath.row == 1) {
                            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 1)];
                            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            [cell addSubview:lineImage];
                            cell.customLabel.hidden = NO;
                            cell.customLabel.text = _getCustomerDetail.informedWay;
                        }else if (indexPath.row == 2) {
                            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 1)];
                            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            [cell addSubview:lineImage];
                            cell.customLabel.hidden = NO;
                            cell.customLabel.text = _getCustomerDetail.intentionLevelRemark;
                        } else if (indexPath.row == 3) {
                            cell.customLabel.hidden = YES;
                            cell.nameLbael.hidden = YES;
                            cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                            b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                            NSString *rcString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                            }else {
                                rcString = [NSString stringWithFormat:@"认筹 | "];
                                
                            }
                            [b1 setTitle:rcString forState:UIControlStateNormal];
                            [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b1.layer.masksToBounds = YES;
                            b1.layer.cornerRadius = 5;
                            [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b1];
                            
                            UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                            NSString *rgString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                            }else {
                                rgString = [NSString stringWithFormat:@"认购 | "];
                            }
                            [b2 setTitle:rgString forState:UIControlStateNormal];
                            [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b2.layer.masksToBounds = YES;
                            b2.layer.cornerRadius = 5;
                            [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b2];
                            
                            UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                            NSString *qyString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                            }else {
                                qyString = [NSString stringWithFormat:@"签约 | "];
                            }
                            
                            [b3 setTitle:qyString forState:UIControlStateNormal];
                            [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b3.layer.masksToBounds = YES;
                            b3.layer.cornerRadius = 5;
                            [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b3];
                            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                            //是否已开通认筹功能：0、未开通；1、已开通
#warning xiugxianshi---RC
                            NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                            if ([isPaydeposit isEqualToString:@"0"]) {
                                b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }else {
                                [cell addSubview:b1];
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }
                        }
                    }else {
                        if (indexPath.row == 1) {
                            cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 1)];
                            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            [cell addSubview:lineImage];
                            cell.customLabel.hidden = NO;
                            cell.customLabel.text = _getCustomerDetail.informedWay;
                        }else if (indexPath.row == 2) {
                            cell.customLabel.hidden = YES;
                            cell.nameLbael.hidden = YES;
                            cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                            UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                            b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                            NSString *rcString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                            }else {
                                rcString = [NSString stringWithFormat:@"认筹 | "];
                                
                            }
                            [b1 setTitle:rcString forState:UIControlStateNormal];
                            [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b1.layer.masksToBounds = YES;
                            b1.layer.cornerRadius = 5;
                            [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b1];
                            
                            UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                            NSString *rgString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                            }else {
                                rgString = [NSString stringWithFormat:@"认购 | "];
                            }
                            [b2 setTitle:rgString forState:UIControlStateNormal];
                            [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b2.layer.masksToBounds = YES;
                            b2.layer.cornerRadius = 5;
                            [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b2];
                            
                            UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                            b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                            b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                            NSString *qyString;
                            if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                                qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                            }else {
                                qyString = [NSString stringWithFormat:@"签约 | "];
                            }
                            
                            [b3 setTitle:qyString forState:UIControlStateNormal];
                            [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                            b3.layer.masksToBounds = YES;
                            b3.layer.cornerRadius = 5;
                            [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                            //                        [cell addSubview:b3];
                            NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                            //是否已开通认筹功能：0、未开通；1、已开通
#warning xiugxianshi---RC
                            NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                            if ([isPaydeposit isEqualToString:@"0"]) {
                                b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }else {
                                [cell addSubview:b1];
                                [cell addSubview:b2];
                                [cell addSubview:b3];
                            }
                        }
                    }
                }
            }else {
                if ([necessary isEqualToString:@"1"] && [NSString isStringEmpty2:_getCustomerDetail.intentionLevelRemark] == NO) {
                    if (indexPath.row == 1) {
                        cell.nameLbael.text = [grouparr0 objectAtIndex:indexPath.row];
                        UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, EMM_WIDTH-20, 1)];
                        lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                        [cell addSubview:lineImage];
                        cell.customLabel.hidden = NO;
                        cell.customLabel.text = _getCustomerDetail.intentionLevelRemark;
                    }else if (indexPath.row == 2) {
                        cell.customLabel.hidden = YES;
                        cell.nameLbael.hidden = YES;
                        cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                        UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                        b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                        NSString *rcString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                        }else {
                            rcString = [NSString stringWithFormat:@"认筹 | "];
                            
                        }
                        [b1 setTitle:rcString forState:UIControlStateNormal];
                        [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b1.layer.masksToBounds = YES;
                        b1.layer.cornerRadius = 5;
                        [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                        //                    [cell addSubview:b1];
                        
                        UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                        b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                        NSString *rgString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                        }else {
                            rgString = [NSString stringWithFormat:@"认购 | "];
                        }
                        [b2 setTitle:rgString forState:UIControlStateNormal];
                        [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b2.layer.masksToBounds = YES;
                        b2.layer.cornerRadius = 5;
                        [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                        //                    [cell addSubview:b2];
                        
                        UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                        b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                        NSString *qyString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                        }else {
                            qyString = [NSString stringWithFormat:@"签约 | "];
                        }
                        
                        [b3 setTitle:qyString forState:UIControlStateNormal];
                        [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b3.layer.masksToBounds = YES;
                        b3.layer.cornerRadius = 5;
                        [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                        
                        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                        //是否已开通认筹功能：0、未开通；1、已开通
                        NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                        if ([isPaydeposit isEqualToString:@"0"]) {
                            b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                            b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                            [cell addSubview:b2];
                            [cell addSubview:b3];
                        }else {
                            [cell addSubview:b1];
                            [cell addSubview:b2];
                            [cell addSubview:b3];
                        }
                    }
                }else {
                    if (indexPath.row == 1) {
                        cell.customLabel.hidden = YES;
                        cell.nameLbael.hidden = YES;
                        cell.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                        UIButton *b1 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b1.frame = CGRectMake(10, 10, EMM_WIDTH/3-15, 35);
                        b1.backgroundColor = [UIColor colorFromHexCode:@"#ff821c"];
                        NSString *rcString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            rcString = [NSString stringWithFormat:@"认筹 | %@",_getCustomerDetail.payDepositNum];
                        }else {
                            rcString = [NSString stringWithFormat:@"认筹 | "];
                            
                        }
                        [b1 setTitle:rcString forState:UIControlStateNormal];
                        [b1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b1.layer.masksToBounds = YES;
                        b1.layer.cornerRadius = 5;
                        [b1 addTarget:self action:@selector(tourBtn1Click:) forControlEvents:UIControlEventTouchUpInside];
                        //                    [cell addSubview:b1];
                        
                        UIButton *b2 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b2.frame = CGRectMake(EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                        b2.backgroundColor = [UIColor colorFromHexCode:@"#c72928"];
                        NSString *rgString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            rgString = [NSString stringWithFormat:@"认购 | %@",_getCustomerDetail.subscribeNum];
                        }else {
                            rgString = [NSString stringWithFormat:@"认购 | "];
                        }
                        [b2 setTitle:rgString forState:UIControlStateNormal];
                        [b2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b2.layer.masksToBounds = YES;
                        b2.layer.cornerRadius = 5;
                        [b2 addTarget:self action:@selector(tourBtn2Click:) forControlEvents:UIControlEventTouchUpInside];
                        //                    [cell addSubview:b2];
                        
                        UIButton *b3 = [UIButton buttonWithType:UIButtonTypeSystem];
                        b3.frame = CGRectMake(EMM_WIDTH/3+EMM_WIDTH/3+10, 10, EMM_WIDTH/3-15, 35);
                        b3.backgroundColor = [UIColor colorFromHexCode:@"#7914F5"];
                        NSString *qyString;
                        if ([NSString isStringEmpty2:_getCustomerDetail.subscribeNum] == NO) {
                            qyString = [NSString stringWithFormat:@"签约 | %@",_getCustomerDetail.signedNum];
                        }else {
                            qyString = [NSString stringWithFormat:@"签约 | "];
                        }
                        
                        [b3 setTitle:qyString forState:UIControlStateNormal];
                        [b3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
                        b3.layer.masksToBounds = YES;
                        b3.layer.cornerRadius = 5;
                        [b3 addTarget:self action:@selector(tourBtn3Click:) forControlEvents:UIControlEventTouchUpInside];
                        
                        NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
                        //是否已开通认筹功能：0、未开通；1、已开通
                        NSString *isPaydeposit = [userdf objectForKey:@"isPaydeposit"];
                        if ([isPaydeposit isEqualToString:@"0"]) {
                            b2.frame = CGRectMake((EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                            b3.frame = CGRectMake(EMM_WIDTH/2+(EMM_WIDTH/2-EMM_WIDTH/3)/2, 10, EMM_WIDTH/3, 35);
                            [cell addSubview:b2];
                            [cell addSubview:b3];
                        }else {
                            [cell addSubview:b1];
                            [cell addSubview:b2];
                            [cell addSubview:b3];
                        }
                    }
                }
            }
            return cell;
        }
        return cell;
    }else if ([indexStr isEqualToString:@"1"]) {
#warning 修改跟进Cell
        FollowList *list;
        if (_gjDataArr.count > 0) {
            list = [_gjDataArr objectAtIndex:indexPath.row];
            
            NSMutableArray *arr = [[NSMutableArray alloc] init];
            if (list.contentList.count > 0) {
                for (ContentList *cList in list.contentList) {
                    [arr addObject:cList];
                }
            }
            
            if ([list.followType isEqualToString:@"2"]) {
                static NSString *CellIdentifier = @"FollowThreeCellId";
                FollowThreeCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
                if (cell == nil) {
                    cell = [[[NSBundle mainBundle] loadNibNamed:@"FollowThreeCell" owner:self options:nil] lastObject];
                }
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 59, EMM_WIDTH-20, 1)];
                lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                //            [cell addSubview:lineImage];
                if (arr.count > 0) {
                    ContentList *cList = arr[0];
                    [cell.tpImageView sd_setImageWithURL:[NSURL URLWithString:cList.followContent] placeholderImage:nil];
                    cell.tpTimerLabel.text = [NSString stringWithFormat:@"(%ld)",arr.count];
                    cell.tpTimerLabel.textColor = [UIColor colorFromHexCode:@"#ff7200"];
                }
                cell.tpTimerTwoLabel.text = list.followTime;
                cell.tpFollowModeTwoLabel.text = list.followMode;
                return cell;
            }else if ([list.followType isEqualToString:@"3"]) {
                static NSString *CellIdentifier = @"FollowTwoCellId";
                FollowTwoCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
                if (cell == nil) {
                    cell = [[[NSBundle mainBundle] loadNibNamed:@"FollowTwoCell" owner:self options:nil] lastObject];
                }
                cell.selectionStyle = UITableViewCellSelectionStyleNone;
                UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 59, EMM_WIDTH-20, 1)];
                lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
                //            [cell addSubview:lineImage];
                cell.timerTwoLabel.text = list.followTime;
                cell.followModeTwoLabel.text = list.followMode;
                if ([NSString isStringEmpty2:list.voiceTime]) {
                    cell.bfTimerLabel.text = @"00′00″";
                }else{
                    cell.bfTimerLabel.text = [NSString stringWithFormat:@"%@",list.voiceTime];
                }
                return cell;
            }
            static NSString *CellIdentifier = @"FollowOneCellId";
            FollowOneCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
            if (cell == nil) {
                cell = [[[NSBundle mainBundle] loadNibNamed:@"FollowOneCell" owner:self options:nil] lastObject];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 59, EMM_WIDTH-20, 1)];
            lineImage.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
            //        [cell addSubview:lineImage];
            ContentList *cList = arr[0];
//            cell.titleLabel.text = cList.followContent;
            NSString *str = [cList.followContent stringByReplacingOccurrencesOfString:@"null" withString:@""];
            NSMutableAttributedString * attrStr = [[NSMutableAttributedString alloc] initWithData:[str dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil];
           [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:15.0f] range:NSMakeRange(0, attrStr.length)]; //关键步骤，设置指定位置文字的字号大小

            cell.titleLabel.attributedText = attrStr;
            cell.timerLabel.font = [UIFont systemFontOfSize:15];
            cell.timerLabel.text = list.followTime;
            cell.followModeLabel.text = list.followMode;
            return cell;
        }
    }
    static NSString *CellIdentifier = @"NewCustDetailsCell";
    NewCustDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"NewCustDetailsCell" owner:self options:nil] lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    UIImageView *lineImage = [[UIImageView alloc] initWithFrame:CGRectMake(10, 49.5, EMM_WIDTH-20, 0.5)];
    lineImage.backgroundColor = [UIColor colorFromHexCode:@"#CCCCCC"];
    [cell addSubview:lineImage];
    
    if ([selectedArr containsObject:indexStr]) {
        cell.nameLbael.text = dic[indexStr][indexPath.row];
    }
    
    if ([indexStr isEqualToString:@"2"]) {
        cell.customLabel.textColor = [UIColor blackColor];
        if (indexPath.row == 0) {//置业动机
            cell.customLabel.text = _getCustomerDetail.rqTheirMotives;
        }else if (indexPath.row == 1) {//关注重点
            if (_subCellHightRow1 == 50) {
                [cell addSubview:lineImage];
            }
            cell.nameLbael.hidden = YES;
            UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 100, 20)];
            nameL.text = @"关注重点";
            nameL.font = [UIFont systemFontOfSize:15];
            nameL.textColor = [UIColor colorFromHexCode:@"#5A5A5A"];
            [cell addSubview:nameL];
            _subCellIndeRow1TableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, EMM_WIDTH,_subCellHightRow1-50) style:UITableViewStylePlain];
            _subCellIndeRow1TableView.delegate = self;
            _subCellIndeRow1TableView.dataSource = self;
            _subCellIndeRow1TableView.showsVerticalScrollIndicator = NO;
            _subCellIndeRow1TableView.scrollEnabled = NO;
            _subCellIndeRow1TableView.separatorStyle = UITableViewCellSeparatorStyleNone;
            [cell addSubview:_subCellIndeRow1TableView];
        }else if (indexPath.row == 2) {//需求面积
            if ([NSString isStringEmpty2:_getCustomerDetail.rqDemandArea] == NO) {
                cell.customLabel.text = _getCustomerDetail.rqDemandArea;
            }else {
                cell.customLabel.text = @"";
            }
        }else if (indexPath.row == 3) {//付款方式
            cell.customLabel.text = _getCustomerDetail.rqPaymentMethod;
        }
//        else if (indexPath.row == 4) {//意向房源
//            if (_subCellHightRow4 == 50) {
//                [cell addSubview:lineImage];
//            }
//            cell.nameLbael.hidden = YES;
//
//            UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 100, 20)];
//            nameL.text = @"意向房源";
//            nameL.font = [UIFont systemFontOfSize:15];
//            nameL.textColor = [UIColor colorFromHexCode:@"#5A5A5A"];
//            [cell addSubview:nameL];
//
//            _subCellIndeRow4TableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, EMM_WIDTH,_subCellHightRow4-50) style:UITableViewStylePlain];
//            _subCellIndeRow4TableView.delegate = self;
//            _subCellIndeRow4TableView.dataSource = self;
//            _subCellIndeRow4TableView.showsVerticalScrollIndicator = NO;
//            _subCellIndeRow4TableView.scrollEnabled = NO;
//            _subCellIndeRow4TableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//            [cell addSubview:_subCellIndeRow4TableView];
//
//            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(15, _subCellHightRow4 - 45, EMM_WIDTH-30, 40)];
//            view.backgroundColor = [UIColor whiteColor];
//            view.layer.borderWidth = 1.0f;
//            view.layer.borderColor = [[UIColor colorFromHexCode:@"#E4E4E4"] CGColor];
//            view.layer.masksToBounds = YES;
//            view.layer.cornerRadius = 5;
//            if (_zongRoomList.count > 3) {
//                [cell addSubview:view];
//                UIImageView *lineIm = [[UIImageView alloc] initWithFrame:CGRectMake(10, _subCellHightRow4-1, EMM_WIDTH-20, 1)];
//                lineIm.backgroundColor = [UIColor colorFromHexCode:@"#e4e4e4"];
//                [cell addSubview:lineIm];
//            }
//
//            UILabel *zkLabel = [[UILabel alloc] initWithFrame:CGRectMake(view.frame.size.width/2-100, 10, 100, 20)];
//            zkLabel.font = [UIFont systemFontOfSize:15];
//            zkLabel.textAlignment = NSTextAlignmentRight;
//            [view addSubview:zkLabel];
//
//            UIImageView *zkImageView = [[UIImageView alloc] initWithFrame:CGRectMake(view.frame.size.width/2+5, 12.5, 18, 15)];
//            [view addSubview:zkImageView];
//            if (_iszkFlas == YES) {
//                zkLabel.text = @"展开";
//                zkImageView.image = [UIImage imageNamed:@"cha_10"];
//            }else {
//                zkLabel.text = @"收起";
//                zkImageView.image = [UIImage imageNamed:@"cha_08"];
//            }
//
//            UIButton *zkButton = [UIButton buttonWithType:UIButtonTypeSystem];
//            zkButton.frame = CGRectMake(0, 0, view.frame.size.width, view.frame.size.height);
//            [zkButton addTarget:self action:@selector(zkButtonClick:) forControlEvents:UIControlEventTouchUpInside];
//            [view addSubview:zkButton];
//
//        }
        else if (indexPath.row == 4) {//生活服务
            if (_subCellHightRow5 == 50) {
                [cell addSubview:lineImage];
            }
            cell.nameLbael.hidden = YES;
            UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(10, 15, 100, 20)];
            nameL.text = @"生活服务";
            nameL.font = [UIFont systemFontOfSize:15];
            nameL.textColor = [UIColor colorFromHexCode:@"#5A5A5A"];
            [cell addSubview:nameL];
            _subCellIndeRow5TableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 50, EMM_WIDTH,_subCellHightRow5-50) style:UITableViewStylePlain];
            _subCellIndeRow5TableView.delegate = self;
            _subCellIndeRow5TableView.dataSource = self;
            _subCellIndeRow5TableView.showsVerticalScrollIndicator = NO;
            //不要分割线
            _subCellIndeRow5TableView.scrollEnabled = NO;
            _subCellIndeRow5TableView.separatorStyle = UITableViewCellSeparatorStyleNone;
            [cell addSubview:_subCellIndeRow5TableView];
        }
    }else if ([indexStr isEqualToString:@"3"]) {
        cell.customLabel.hidden = NO;
        if (indexPath.row == 0) {//首次接触
            NSString *type = _getCustomerDetail.ftContactWay ?  _getCustomerDetail.ftContactWay : _getCustomerDetail.ftContactWay1;
            cell.customLabel.text = type;
        }else if (indexPath.row == 1) {//首次接触时间
             NSString *time = _getCustomerDetail.ftContactTime ?  _getCustomerDetail.ftContactTime : _getCustomerDetail.ftContactTime1;
            cell.customLabel.text = time;
        }else if (indexPath.row == 2) {//沟通内容
            lineImage.hidden = YES;
             NSString *note = _getCustomerDetail.ftContactContent ?  _getCustomerDetail.ftContactContent : _getCustomerDetail.ftContactContent1;
            cell.customLabel.text = note;
            CGSize titleSize = [note boundingRectWithSize:CGSizeMake(EMM_WIDTH - 107, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
            if (titleSize.height > 18) {
                cell.customLabel.textAlignment = NSTextAlignmentLeft;
            }
        }else if (indexPath.row == 3) {
             cell.customLabel.text = _getCustomerDetail.ftContactWay1;
        }else if (indexPath.row == 4) {//首次接触时间
            cell.customLabel.text = _getCustomerDetail.ftContactTime1;
        }else if (indexPath.row == 5) {//沟通内容
            lineImage.hidden = YES;
            cell.customLabel.text = _getCustomerDetail.ftContactContent1;
            CGSize titleSize = [_getCustomerDetail.ftContactContent1 boundingRectWithSize:CGSizeMake(EMM_WIDTH - 107, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]} context:nil].size;
            if (titleSize.height > 18) {
                cell.customLabel.textAlignment = NSTextAlignmentLeft;
            }
        }
    }else if ([indexStr isEqualToString:@"4"]) {
        cell.customLabel.hidden = NO;
        if (indexPath.row == 0) {//居住区
            if ([NSString isStringEmpty2:_getCustomerDetail.peResidence] == NO) {
                cell.customLabel.text = _getCustomerDetail.peResidence;
            }
        }else if (indexPath.row == 1) {//工作区
            if ([NSString isStringEmpty2:_getCustomerDetail.peWorkaround] == NO) {
                cell.customLabel.text = _getCustomerDetail.peWorkaround;
            }
        }else if (indexPath.row == 2) {//从事行业
            if ([NSString isStringEmpty2:_getCustomerDetail.industry] == NO) {
                cell.customLabel.text = _getCustomerDetail.industry;
            }
        }
    }else if ([indexStr isEqualToString:@"5"]) {
        cell.nameLbael.textColor = [UIColor colorFromHexCode:@"#1A1A1A"];
        UIButton *questionnaireBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        questionnaireBtn.frame = cell.frame;
        [questionnaireBtn addTarget:self action:@selector(questionnaireBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        questionnaireBtn.tag = indexPath.row + 100;
        [cell addSubview:questionnaireBtn];
    }else if ([indexStr isEqualToString:@"6"]) {
        cell.nameLbael.textColor = [UIColor colorFromHexCode:@"#1A1A1A"];
        UIButton *tagListBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        tagListBtn.frame = cell.frame;
        [tagListBtn addTarget:self action:@selector(tagListBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        tagListBtn.tag = indexPath.row + 100;
        [cell addSubview:tagListBtn];
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *indexStr = [NSString stringWithFormat:@"%ld",indexPath.section];
    if (tableView == _tableView) {
        if ([indexStr isEqualToString:@"1"]) {
            if (_gjDataArr.count > 0) {
                FollowList *list = [_gjDataArr objectAtIndex:indexPath.row];
                
                NSMutableArray *arr = [[NSMutableArray alloc] init];
                NSMutableArray *arrImageV = [[NSMutableArray alloc] init];
                
                if (list.contentList.count > 0) {
                    for (ContentList *cList in list.contentList) {
                        [arr addObject:cList];
                        [arrImageV addObject:cList.followContent];
                    }
                }
                
                if ([list.followType isEqualToString:@"3"]) {
                    NSString *url;
                    for (int i = 0; i < arr.count; i++) {
                        ContentList *cList = [arr objectAtIndex:i];
                        url = cList.followContent;
                    }
                    if (url == nil) {
                        return;
                    }
                    [[CustomPlayer sharedInstance] setCustomPlayerStr:url];
                    [[CustomPlayer sharedInstance] setCustomPlayerIsShowPlayView:^(BOOL isShow) {
                        [[CustomPlayer sharedInstance] sourcePlay];
                    }];
                    
                    [[CustomPlayer sharedInstance] setCustomPlayerShowFinish:^(NSString *timer) {
                        NSLog(@"%@",timer);
                        [[CustomPlayer sharedInstance] removeObserverAndNotification];
                        [self creatPlayViewRemoveFromSuperview];
                    }];
                    
                    _playView = [[PlayAnimationView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, EMM_HEIGHT)];
                    _playView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
                    [[UIApplication sharedApplication].keyWindow addSubview:_playView];
                    __weak TouristsDetailsViewController *weakMenuView = self;
                    [_playView setPlayAnimationBlock:^{
                        //                [[CustomPlayer sharedInstance] sourceStop];
                        [[CustomPlayer sharedInstance] removeObserverAndNotification];
                        [weakMenuView creatPlayViewRemoveFromSuperview];
                    }];
                }else if ([list.followType isEqualToString:@"2"]) {
                    if (arrImageV.count > 0) {
                        MHPhotoBrowserController *vc = [MHPhotoBrowserController new];
                        NSMutableArray * bigImgArray = [NSMutableArray new];
                        for (int i = 0; i < arrImageV.count; i++) {
                            NSString *url = [arrImageV objectAtIndex:i];
                            NSString *url1 = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
                            [bigImgArray addObject:[MHPhotoModel photoWithURL:[NSURL URLWithString:url1]]];
                        }
                        vc.currentImgIndex = 0;
                        vc.displayTopPage = YES;
                        vc.displayDeleteBtn = YES;
                        vc.imgArray = bigImgArray;
                        //        vc.isShouDel = 1;
                        vc.displayDeleteBtn = NO;
                        [self presentViewController:vc animated:YES completion:nil];
                    }else {
                        [self showToast:@"暂无图片预览"];
                    }
                }
            }
        }
    }
}

#pragma mark - 意向房源展开和收起
- (void)zkButtonClick:(UIButton *)btn {
    [_roomList removeAllObjects];
    if (_iszkFlas == YES) {
        for (int i = 0; i < _zongRoomList.count; i++) {
            RoomList *list = [_zongRoomList objectAtIndex:i];
            [_roomList addObject:list];
        }
        _subCellHightRow4 = (int)_roomList.count * 50 + 100;
        _iszkFlas = NO;
    }else {
        RoomList *list = [_zongRoomList objectAtIndex:0];
        [_roomList addObject:list];
        RoomList *list1 = [_zongRoomList objectAtIndex:1];
        [_roomList addObject:list1];
        RoomList *list2 = [_zongRoomList objectAtIndex:2];
        [_roomList addObject:list2];
        _subCellHightRow4 = (int)_roomList.count * 50 + 100;
        _iszkFlas = YES;
    }
    [_subCellIndeRow4TableView reloadData];
    [_tableView reloadData];
}

#pragma amrk - 移除播放动画
// _playView
- (void)creatPlayViewRemoveFromSuperview {
    [_playView removeFromSuperview];
    _playView = nil;
}

#pragma mark - 认筹
- (void)tourBtn1Click:(UIButton *)btn {
    KnowViewController *kvc = [[KnowViewController alloc] init];
    kvc.customerId = _customerId;
    kvc.getCustomerDetail = _getCustomerDetail;
    kvc.paymentMethod = _getCustomerDetail.rqPaymentMethod;
    [self.navigationController pushViewController:kvc animated:YES];
    [kvc setNewCustomersBlock:^{
        [self postGetCustomerDetailApi];
    }];
}
#pragma mark - 认购
- (void)tourBtn2Click:(UIButton *)btn {

    SubscriptionViewController *kvc = [[SubscriptionViewController alloc] init];
    kvc.customerId = _customerId;
    kvc.paymentMethod = _getCustomerDetail.rqPaymentMethod;
    kvc.getCustomerDetail = _getCustomerDetail;
    [self.navigationController pushViewController:kvc animated:YES];
    [kvc setNewCustomersBlock:^{
        [self postGetCustomerDetailApi];
    }];
}

#pragma mark - 签约
- (void)tourBtn3Click:(UIButton *)btn {
    SignViewController *kvc = [[SignViewController alloc] init];
    kvc.customerId = _customerId;
    kvc.getCustomerDetail = _getCustomerDetail;
    kvc.paymentMethod = _getCustomerDetail.rqPaymentMethod;
    [self.navigationController pushViewController:kvc animated:YES];
    [kvc setNewCustomersBlock:^{  
        [self postGetCustomerDetailApi];
    }];
}


-(void)doButton:(UIButton *)sender {
    NSString *string = [NSString stringWithFormat:@"%ld",sender.tag-100];
    //数组selectedArr里面存的数据和表头想对应，方便以后做比较
    if ([selectedArr containsObject:string]) {
        [selectedArr removeObject:string];
    }else {
        [selectedArr addObject:string];
    }
    [_tableView reloadData];
}

#pragma mark - 分配
- (void)postDistributionConsultantApiConsultantUserId:(NSString *)consultantUserId customerList:(NSArray *)customerList {
    
    DistributionConsultantApi *api = [[DistributionConsultantApi alloc] initWithConsultantUserId:consultantUserId customerList:customerList];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        DistributionConsultantApi *result = (DistributionConsultantApi *)request;
        if (result.isSuccess) {
//            DistributionConsultant *get = result.resultData;
            [self showToast:@"分配成功"];
        } else {
            [self showToast:result.resultData.errorMsg];
            
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}


//- (void)phoneSDetailsbtnAction:(UIButton *)sender {
////    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
////
////    NSString *isPhoneInformation = [userdf objectForKey:@"isPhoneInformation"];
////    if ([NSString isStringEmpty2:isPhoneInformation] == NO) {
////        if ([isPhoneInformation isEqualToString:@"0"]) {
////            NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getCustomerDetail.customerPhone];
////            UIWebView * callWebview = [[UIWebView alloc] init];
////            [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
////            [self.view addSubview:callWebview];
////
////        }else if ([isPhoneInformation isEqualToString:@"1"]) {
////            [self postGetUserCallListApi];
////        }
////    }else {
////        NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getCustomerDetail.customerPhone];
////        UIWebView * callWebview = [[UIWebView alloc] init];
////        [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
////        [self.view addSubview:callWebview];
////
////    }
//    [self postGetUserCallListApi];
//
//}

#pragma mark - 动态计算行高
- (CGFloat)textHeightFromTextString:(NSString *)text width:(CGFloat)textWidth fontSize:(CGFloat)textSize {
    CGRect rect = [text boundingRectWithSize:CGSizeMake(textWidth, MAXFLOAT) options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:textSize]} context:nil];
    //返回计算出的行高
    return ceilf(rect.size.height);
}


#pragma maek - 电话平台调用方法

- (void)postGetUserCallListApi {
    [self showHudInWindow:@"正在加载中..."];
    GetUserCallListApi *api = [[GetUserCallListApi alloc] initWith];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetUserCallListApi *result = (GetUserCallListApi *)request;
        //请求成功
        if (result.isSuccess) {
            GetUserCallList *get = result.resultData;
            
            if ([NSString isStringEmpty2:get.isPhoneInformation] == NO) {
                if ([get.isPhoneInformation isEqualToString:@"0"]) {
                    NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getCustomerDetail.customerPhone];
                    UIWebView * callWebview = [[UIWebView alloc] init];
                    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
                    [self.view addSubview:callWebview];
                }else {
                    UserCallMenuView *userListV = [[UserCallMenuView alloc] initWithFrame:CGRectMake(0, 0, EMM_WIDTH, EMM_HEIGHT) title:@"选择拨打号码" nameArr:get.userCallList];
                    userListV.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
                    [[UIApplication sharedApplication].keyWindow addSubview:userListV];
                    __weak UserCallMenuView *weakMenuView = userListV;
                    [userListV setTouchUserCallMenuViewBlock:^(NSString *telePhone, NSString *telePhoneType) {
                        NSLog(@"%@-%@",telePhone,telePhoneType);
                        if ([NSString isStringEmpty2:telePhone] == NO) {
                            [self postGetCallBackApiTelePhoneString:telePhone];
                        }
                        [weakMenuView removeFromSuperview];
                    }];
                }
            }else {
                NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",_getCustomerDetail.customerPhone];
                UIWebView * callWebview = [[UIWebView alloc] init];
                [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
                [self.view addSubview:callWebview];
            }
        } else {
            
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

- (void)postGetCallBackApiTelePhoneString:(NSString *)telePhoneString {
    GetCallBackApi *api = [[GetCallBackApi alloc] initWithCustomerId:self.customerId caller:telePhoneString called:_getCustomerDetail.customerPhone terminalModel:@"0" terminalModelId:self.customerId];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetCallBackApi *result = (GetCallBackApi *)request;
        //请求成功
        if (result.isSuccess) {
            GetCallBack *get = result.resultData;
            FollowUpViewController *fvc = [[FollowUpViewController alloc] init];
            fvc.customerId = self.customerId;
            fvc.followId = get.followId;
            [self.navigationController pushViewController:fvc animated:YES];
            [fvc setFollowUpViewBlock:^{
            }];
        } else {
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

#pragma mark - 自定义问卷
- (void)postQueryProjectQuestionnaireListApi {
    [_grouparr5 removeAllObjects];
    [_questionnaireListDataArr removeAllObjects];
    
    QueryProjectQuestionnaireListApi *api = [[QueryProjectQuestionnaireListApi alloc] initWith];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        QueryProjectQuestionnaireListApi *result = (QueryProjectQuestionnaireListApi *)request;
        //请求成功
        if (result.isSuccess) {
            QueryProjectQuestionnaireList *get = result.resultData;
            for (QuestionnaireList *list in get.appProjectQuestionnaireList) {
                [_questionnaireListDataArr addObject:list];
            }
            for (int i = 0; i < _questionnaireListDataArr.count; i++) {
                QuestionnaireList *list = [_questionnaireListDataArr objectAtIndex:i];
                [_grouparr5 addObject:list.questionnaireName];
            }
            [dic setValue:_grouparr5 forKey:@"5"];
            [self initDataSource];
        } else {
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
        [_tableView reloadData];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

#pragma mark - 获取标签分类
- (void)GetTagListApi {
    [_grouparr6 removeAllObjects];
    [_getTagListDataArray removeAllObjects];
    
    GetTagListApi *api = [[GetTagListApi alloc] initWith];
    [api startWithCompletionBlockWithSuccess:^(YTKBaseRequest *request) {
        GetTagListApi *result = (GetTagListApi *)request;
        //请求成功
        if (result.isSuccess) {
            GetTagList *get = result.resultData;
            for (TagList *list in get.tagList) {
                [_getTagListDataArray addObject:list];
            }
            
            for (int i = 0; i < _getTagListDataArray.count; i++) {
                TagList *list = [_getTagListDataArray objectAtIndex:i];
                [_grouparr6 addObject:list.tagName];
            }
            [dic setValue:_grouparr6 forKey:@"6"];
            [self initDataSource];
        } else {
            if ([result.resultData.errorCode isEqualToString:@"YUplf0wyU5vPVssLSG"] || [result.resultData.errorCode isEqualToString:@"108E65843mYuwqb01X"]) {
                NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
                NSDictionary *dictionary = [defs dictionaryRepresentation];
                for(NSString *key in [dictionary allKeys]){
                    if ([key isEqualToString:@"DeviceToken123"] ||
                        [key isEqualToString:@"loginText"] ||
                        [key isEqualToString:@"provinceCityDistrict"]) {
                    }else {
                        [defs removeObjectForKey:key];
                        [defs synchronize];
                    }
                }
                UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"温馨提示" message:result.resultData.errorMsg preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
                    [appInstance showLogin];
                }];
                [alertController addAction:cancelAction];
                [self presentViewController:alertController animated:YES completion:nil];
            }
        }
        [self hideHud];
        [_tableView reloadData];
    } failure:^(YTKBaseRequest *request) {
        [self showToast:@"连接服务器失败，请检查网络！"];
        [self hideHud];
    }];
}

#pragma makr - 自定义跳转
- (void)questionnaireBtnClick:(UIButton *)btn {
    QuestionnaireList *list = [_questionnaireListDataArr objectAtIndex:btn.tag - 100];
    NSString *url = nil;
    NSString *body = nil;
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *merchantId = [userdf objectForKey:@"merchantId"];
    NSString *userId = [userdf objectForKey:@"userNameId"];
    NSString *token = [userdf objectForKey:@"is_login"];
    NSString *projectCode = [userdf objectForKey:@"projectCode"];
    NSString *projectId = [userdf objectForKey:@"projectId"];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:apiVersion forKey:@"version"];
    [params setValue:[IDTools devId2] forKey:@"terminalCode"];
    [params setValue:merchantId forKey:@"merchantId"];
    [params setValue:userId forKey:@"userId"];
    [params setValue:token forKey:@"token"];
    [params setValue:projectId forKey:@"projectId"];
    [params setValue:projectCode forKey:@"projectCode"];
    [params setValue:list.questionnaireId forKey:@"questionnaireId"];
    [params setValue:self.customerId forKey:@"customerId"];

    body = [@{@"params" : params} JSONString];
    
    url = [NSString stringWithFormat:@"%@%@?body=%@",apiBaseUrl,list.answerUrl,body];
    
    NSLog(@"%@:\n %@%@?body=%@", list.answerUrl, apiBaseUrl, list.answerUrl, body);
    
    EMMBaseWebViewController *baseWeb = [[EMMBaseWebViewController alloc] init];
    baseWeb.urlStr = url;
    baseWeb.titleString = list.questionnaireName;
    [self.navigationController pushViewController:baseWeb animated:NO];
}

- (void)tagListBtnClick:(UIButton *)btn {
    TagList *list = [_getTagListDataArray objectAtIndex:btn.tag - 100];
    NSString *url = nil;
    NSString *body = nil;
    NSString *nameStr = @"/appapi/toCusTagList";
    
    NSUserDefaults *userdf = [NSUserDefaults standardUserDefaults];
    NSString *userId = [userdf objectForKey:@"userNameId"];
    NSString *projectId = [userdf objectForKey:@"projectId"];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:@"" forKey:@"version"];
    [params setValue:@"" forKey:@"token"];
    [params setValue:@"" forKey:@"sign"];
    [params setValue:userId forKey:@"userId"];
    [params setValue:projectId forKey:@"projectId"];
    [params setValue:list.tagId forKey:@"typeId"];
    [params setValue:self.customerId forKey:@"customerId"];
    
    body = [@{@"params" : params} JSONString];
    
    url = [NSString stringWithFormat:@"%@%@?body=%@",apiBaseUrl, nameStr, body];
    
    NSLog(@"toCusTagList:\n %@%@?body=%@", apiBaseUrl, nameStr, body);
    
    EMMBaseWebViewController *baseWeb = [[EMMBaseWebViewController alloc] init];
    baseWeb.urlStr = url;
    baseWeb.titleString = list.tagName;
    [self.navigationController pushViewController:baseWeb animated:NO];
}

@end
